//
//  AdtUser.m
//  QiYReader
//
//  Created by 奇阅科技 on 14-11-15.
//  Copyright (c) 2014年 奇阅科技. All rights reserved.
//

#import "AdtUser.h"

@implementation AdtUser
+(NSString *)getTableName
{
    return @"AdtUser";
}
-(instancetype)init{
    self = [super init];
    if (self) {
        self.auto_subscription = YES;
    }
    return self;
}
- (id)initWithCoder:(NSCoder *)decoder {
    self = [super init];
    if (self != nil) {
        self.uid = [decoder decodeObjectForKey:@"uid"];
        self.username = [decoder decodeObjectForKey:@"username"];
        self.mobile = [decoder decodeObjectForKey:@"mobile"];
        self.email= [decoder decodeObjectForKey:@"email"];
        self.token= [decoder decodeObjectForKey:@"token"];
        self.vip_level= [decoder decodeObjectForKey:@"vip_level"];
        self.is_baoyue= [decoder decodeObjectForKey:@"is_baoyue"];
        self.nickname= [decoder decodeObjectForKey:@"nickname"];
        self.headimg= [decoder decodeObjectForKey:@"headimg"];
        self.remain= [decoder decodeObjectForKey:@"remain"];
        self.points= [decoder decodeObjectForKey:@"points"];
        self.experience= [decoder decodeObjectForKey:@"experience"];
        self.needs_experience= [decoder decodeObjectForKey:@"needs_experience"];
        self.hadBuyNum= [decoder decodeObjectForKey:@"hadBuyNum"];
        self.bookReviewNum= [decoder decodeObjectForKey:@"bookReviewNum"];
        self.collectionNum= [decoder decodeObjectForKey:@"collectionNum"];
        self.auto_subscription = [decoder decodeBoolForKey:@"auto_subscription"];
    }
    return self;
}

- (void)encodeWithCoder:(NSCoder *)encoder {
    [encoder encodeObject:self.uid forKey:@"uid"];
    [encoder encodeObject:self.username forKey:@"username"];
    [encoder encodeObject:self.mobile forKey:@"mobile"];
    [encoder encodeObject:self.email forKey:@"email"];
    [encoder encodeObject:self.token forKey:@"token"];
    [encoder encodeObject:self.vip_level forKey:@"vip_level"];
    [encoder encodeObject:self.is_baoyue forKey:@"is_baoyue"];
    [encoder encodeObject:self.nickname forKey:@"nickname"];
    [encoder encodeObject:self.headimg forKey:@"headimg"];
    [encoder encodeObject:self.remain forKey:@"remain"];
    [encoder encodeObject:self.points forKey:@"points"];
    [encoder encodeObject:self.experience forKey:@"experience"];
    [encoder encodeObject:self.needs_experience forKey:@"needs_experience"];
    [encoder encodeObject:self.hadBuyNum forKey:@"hadBuyNum"];
    [encoder encodeObject:self.bookReviewNum forKey:@"bookReviewNum"];
    [encoder encodeObject:self.collectionNum forKey:@"collectionNum"];
    [encoder encodeBool:self.auto_subscription forKey:@"auto_subscription"];
}
+(AdtUser *)getFromDict:(NSDictionary *)dict{
    AdtUser *user = [AdtUser new];
    user.uid = [dict objectForKey:@"uid"];
    user.username = [dict objectForKey:@"username"];
    user.mobile = [dict objectForKey:@"mobile"];
    user.email = [dict objectForKey:@"email"];
    user.token = [dict objectForKey:@"token"];
    user.vip_level = [dict objectForKey:@"vip_level"];
    user.is_baoyue = [dict objectForKey:@"is_baoyue"];
    user.nickname = [dict objectForKey:@"nickname"];
    user.headimg = [dict objectForKey:@"headimg"];
    user.remain = [dict objectForKey:@"remain"];
    if (user.remain.length <1) {
        user.remain = @"0";
    }
    user.points = [dict objectForKey:@"points"];
    if (user.points.length<1) {
        user.points = @"0";
    }
    user.hadBuyNum = [dict objectForKey:@"hadBuyNum"];
    if (user.hadBuyNum.length<1) {
        user.hadBuyNum = @"--";
    }
    user.bookReviewNum = [dict objectForKey:@"bookReviewNum"];
    if (user.bookReviewNum.length<1) {
        user.bookReviewNum = @"--";
    }
    user.collectionNum = [dict objectForKey:@"collectionNum"];
    if (user.collectionNum.length<1) {
        user.collectionNum = @"--";
    }
    return user;
}
@end
